package pl.enigmatic.math.graph;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import pl.enigmatic.HasName;


public class RestrictedLeafsTree<L extends HasName, B extends L, T extends AttachedLeafsTree<L, B, T>> extends AttachedLeafsTree<L, B, T> {

	protected RestrictedLeafsTree(final B base, final List<B> baseChildren, final List<L> leafs) {
		super(base, baseChildren, leafs);
	}

	protected RestrictedLeafsTree(final B base, final List<B> baseChildren) {
		super(base, baseChildren);
	}

	protected RestrictedLeafsTree(final B base) {
		super(base);
	}

	public Set<L> getAllLeafs(final Set<L> set) {
		set.addAll(getAllAttachedLeafs());
		for (final Node<B, T> t : getLeafs()) {
			set.add(t.getBase());
		}
		return set;
	}

	public Set<L> getAllLeafs() {
		return getAllLeafs(new HashSet<L>());
	}

}
